# Importing Data
KOREA <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "U1:U239")

# Checking the Imported Data
View(KOREA)
# Creating Time Series Data
KOREA_ts <- ts(KOREA, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
KOREA_ts
sum(is.na(KOREA_ts))
library(forecast)
KOREA_ts <- tsclean(KOREA_ts)
KOREA_ts

# Identification: Plotting the Time Series Data
plot(KOREA_ts)

# Estimating the appropriate model
KOREA_ts_model <- auto.arima(KOREA_ts)
KOREA_ts_model

# Forecasting
options(max.print=1000000)
KOREA_ts_forecast <- forecast (KOREA_ts_model, level=c(95), h=255)
plot(KOREA_ts_forecast)
KOREA_ts_forecast             

# Exporting
write.table(KOREA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/KOREA_TSA.csv", sep=",")
